package com.shumm.mapper;

import com.shumm.po.ClassicFormula;
import com.shumm.vo.FormulaAndCompositionVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//@Component("cfMapper")
@Mapper
public interface ClassicFormulaMapper {
    //添加
    @Insert("insert into ClassicFormula values(null, #{name},#{alias},#{usage1},#{comment})")
    int add(ClassicFormula cf);

    //删除
    @Delete("delete from ClassicFormula where id=#{id}")
    int delete(int id);

    //    @Update("update ClassicFormula set name = #{name} ,alias = #{alias},usage1 = #{usage1},comment = #{comment} where id = #{id}")
    //更新
    int update(ClassicFormula cf);

    //通过id查询
    @Select("select * from ClassicFormula where id = #{id}")
    ClassicFormula selectById(int id);

    //通过name查询
    @Select("select * from classicformula where name=#{name}")
    ClassicFormula selectByName(String name);

    //查询所有
    @Select("select * from ClassicFormula")
    List<ClassicFormula> selectAll();

    @Select("select * from classicformula where alias like \"%\"#{alias}\"%\"")
    List<ClassicFormula> selectByAlias(String alias);

    @Select("select * from classicformula where usage1 like \"%\"#{cm}\"%\"")
    List<ClassicFormula> selectByChineseMedicine(String cm);

    List<FormulaAndCompositionVO> selectComById(int id);
}
